<?php
/**
 * Created by IntelliJ IDEA.
 * User: xingshi
 * Date: 16/4/24
 * Time: 下午8:59
 */
namespace App;

use Auth;

class Permission
{
    private static $SUPER = 100;
    private static $REVIEW = 80;
    private static $SHARE_TASK = 60;
    private static $VIEW_TOPIC = 100;
    private static $USERID_NO_RANK = 19;

    public static function userid_is_super($userid)
    {
        $data = DB::select('select * from users where id=' . $userid . ' and permission>=' . self::$SUPER);
        if (count($data) > 0) return true;
        return false;
    }

    public static function userid_can_review($userid) {
        $data = DB::select('select * from users where id=' . $userid . ' and permission>=' . self::$REVIEW);
    }

    public static function user_can_review()
    {
        return Auth::check() && Auth::user()->permission >= self::$REVIEW;
    }

    public static function user_can_share_task()
    {
        return Auth::check() && Auth::user()->permission >= self::$SHARE_TASK;
    }

    public static function userid_is_norank($userid)
    {
        if ($userid == self::$USERID_NO_RANK) return true;
        return false;
    }

    public static function user_is_super($user = NULL)
    {
        return Auth::check() && Auth::user()->permission >= self::$SUPER;
    }

    public static function user_can_view_topic() {
        return Auth::check() && Auth::user()->permission >= self::$VIEW_TOPIC;
    }

    public static function user_can_talent($userid){
			return Auth::check() && Auth::user()->offer>0;
           }
}

?>
